-- open_grid_probability
-- created by shuzy
-- 翻开格子概率获得物品（1个）

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 开格子时触发
    trigger = function(who, prop, arg)
        assert(who.type == OBJECT_TYPE_USER, "只有玩家能触发");

        local item = tonumber(prop[2]);
        local v = tonumber(prop[3]);
        local pos = arg;
        local bonus = {1, item, 1};

        local rand = DungeonM.getRandSeed("open_grid_probability") % 1000;

        if rand >= v then
            return false;
        else
            BonusM.doBonus(bonus, "open_grid_probability");
        end

        EventMgr.fire(event.OPEN_GRID_MONEY, {["bonus"] = bonus,
            ["pos"] = pos, ["newBonus"] = nil, });

        return v;
    end,

    record = function(target, prop, path)
        return false;
    end
};